package org.demo.texteditor;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.PropertyConfigurator;
import org.boxlayout.gui.BoxLayoutEngine;
import org.boxlayout.gui.BoxLayoutFrame;
import org.boxlayout.gui.VisualElement;
import org.boxlayout.gui.layout.LayoutFactory;
import org.boxlayout.input.keyboard.KeyboardEvent;
import org.boxlayout.input.keyboard.KeyboardListener;

public class TextEditor {

	BoxLayoutEngine ble;
	public TextEditor() {


		final Log log = LogFactory.getLog("main");
		PropertyConfigurator.configure("log4j.properties");
		
		
		BoxLayoutFrame blf  = new BoxLayoutFrame();
		ble = blf.getBoxLayoutEngine();
		ble.setOrtho(true);
		ble.getCamera2d().setViewBoundaries(-10f,10f,-10f,10f);
		ble.addKeyListener(new KeyboardListener() {

			@Override
			public void onEvent(KeyboardEvent keyEvent) {
				//System.out.println(keyEvent.getKeyEvent().getKeyCode());
				if(keyEvent.getKeyEvent().getKeyCode()==0&&keyEvent.getType()==KeyboardEvent.Type.PRESSED){
					System.out.println(ble.getRootElement().serializeToText("  "));
				}

			}
		});
		
		VisualElement root = ble.createElement().setLayout(LayoutFactory.getInstance().getHorizontalLayout())
		
		;
		
		ble.setRootElement(root);
		
		VisualElement ve = ble.createElement().setLayout(LayoutFactory.getInstance().getHorizontalLayout())
		.setText("test").setTexturedText(true).setTextSize(1f);
		;
		
		
		root.add(ve);
		blf.start();
		
	}





	public static void main(String[] args) {
		new TextEditor();

	}

}
